package com.thunbu.thunbu_meeting_system.viewMdel

import androidx.lifecycle.MutableLiveData
import com.thunbu.lib_common.base.CoroutineViewModel
import com.thunbu.lib_common.utils.DeviceUtil
import com.thunbu.thunbu_meeting_system.await
import com.thunbu.thunbu_meeting_system.launch
import com.thunbu.thunbu_meeting_system.service.ApiService
import com.thunbu.thunbu_meeting_system.service.MainNet
import com.thunbu.thunbu_meeting_system.utils.AppUtils


/**
 * @Description:
 * @author: fancl
 * @Date: 2023/3/16 21:26
 */
class AuthorizationViewModel : CoroutineViewModel<Unit>() {
    val mResult = MutableLiveData<Boolean>()

    override fun initModel() {

    }

    fun doBind() {
        launch({
            val result = MainNet.server(ApiService::class.java).createEquipment(DeviceUtil.getDeviceId()).await(true,true)
            AppUtils.setBindResult(true)
        })
    }

    fun doauth(code: String) {
        launch({
            val result = MainNet.server(ApiService::class.java).queryEquipment(DeviceUtil.getDeviceId(),code).await(true,true)
            mResult.value = true
        })
    }
}